<template>
  <div class="container-pt">
    <van-nav-bar left-arrow  @click-left="$router.back()" fixed title="我的点赞"/>
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
    <article-list :disable-swiper="false" v-for="item in userLike" :key="item.id" :item="item">
     <van-button square type="warning" text="取消" @click="del(item.id)"/>
    </article-list>
    </van-list>
  </div>
</template>

<script>
import articleList from '@/components/article-list.vue'
import { articleZan } from '@/api/article'
import request from '@/utils/request'
import { Toast } from 'vant'
export default {
  name: 'zanPage',
  components: { articleList },
  data () {
    return {
      active: 0,
      userLike: [],
      type: '2',
      page: '1',
      limit: '10',
      loading: false,
      finished: false
    }
  },
  async created () {
  },
  methods: {
    async onLoad () {
      const res = await articleZan({ type: this.type, page: this.page, limit: this.limit })
      this.userLike.push(...res.data.list.data)
      this.loading = false
      this.page++
      if (this.page > res.data.list.totalPages) {
        this.finished = true
      }
    },
    async del (index) {
      this.userLike = this.userLike.filter(item => item.id !== index)
      await request.get('/user/userDataHandle', { params: { type: '2', article_id: index, action: 'del' } })
      Toast.success('取消收藏成功！')
    }
  }
}
</script>

<style scoped>
 img{
    width: 100px;
    height: 100px;
  }
</style>
